local awful = require("awful")
local wibox = require("wibox")
local gears = require("gears")
local theme = require("theme")
local dpi	= require("beautiful.xresources").apply_dpi




local taglist = {}






function taglist:setup(s)
	awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" }, s, awful.layout.layouts[1])
	local tag = awful.widget.taglist({
		screen  = s,
		buttons = gears.table.join(
			awful.button({ "Mod4" }, 1, function(t) if client.focus then client.focus:move_to_tag(t) end t:view_only() end),
			awful.button({}, 1, function(t) t:view_only() end)
		),
		filter  = awful.widget.taglist.filter.all,
		widget_template = {
			{
				{
					{
						id     = 'text_role',
						font   = theme.taglist_font,
						widget = wibox.widget.textbox,
					},
					valign = 'center',
					halign = 'center',
					widget = wibox.container.place,
				},
				id     = "background_role",
				forced_width = theme.taglist_width,
				forced_height = theme.taglist_width,
				widget = wibox.container.background,
			},
			shape = function(cr, width, height)
				gears.shape.rounded_rect(cr, width, height, theme.taglist_radius)
			end,
			fg = theme.widget_fg,
			bg = theme.widget_bg,
			widget = wibox.container.background,
		}
	})
	self.widget = wibox.widget{
		{
			{
				{
					widget = tag,
				},
				--top = dpi(2),
				--bottom = dpi(2),
				--left = dpi(2),
				--right = dpi(2),
				widget = wibox.container.margin,
			},
			bg    = theme.taglist_bg,
			shape = function(cr, width, height)
				gears.shape.rounded_rect(cr, width, height, theme.taglist_radius)
			end,
			widget = wibox.container.background,
		},
		margins = theme.widget_margins,
		widget = wibox.container.margin,
		buttons = gears.table.join(
			awful.button({}, 4, function(t) awful.tag.viewnext(t.screen) end),
			awful.button({}, 5, function(t) awful.tag.viewprev(t.screen) end),
			awful.button({}, 9, function(t) awful.tag.viewnext(t.screen) end),
			awful.button({}, 8, function(t) awful.tag.viewprev(t.screen) end)
		),
	}
	return self.widget
end




return taglist
